<% if @record_result.errors.any? %>
  alert("<%= @record_result.errors.values.join(';') %>")
<% else %>
  <% (1..9).each do |i| %>
    <% constitution_score = "constitution_score" + i.to_s %>
    <% real_score = "real_score" + i.to_s %>
    var table = $('#groups').children().eq(<%= i - 1 %>);
    table.find(":checkbox").prop('checked', false);
    table.find("." + "<%= @record_result.send(constitution_score.to_sym) %>").prop('checked', true);
    table.find('.score').text("<%= @record_result.send(real_score.to_sym).to_i %>")
  <% end %>
  $('#score_result').html("<%= j @record_result.score_result %>");
<% end %>
